//
//  RequestAgentInfo.m
//  BaseProject
//
//  Created by 王洋 on 2021/4/12.
//  Copyright © 2021 王洋. All rights reserved.
//

#import "RequestAgentInfo.h"

@implementation RequestAgentInfo

+ (void)request_agentInfoComption:(void (^)(BOOL success, AgentReviewModel *model))comption {

    NSMutableDictionary *dic = @{}.mutableCopy;
    [dic setValue:[TTUserModel sharedObject].userId forKey:@"userId"];
    NSString *url = [NSString stringWithFormat:@"%@%@",TT_Global_Api_Domain,API_AgentInfo];
    [SVProgressHUD showWithStatus:@"正在获取申请状态"];
    [TTHttpManager postRequestWithUrl:url TimeOut:10 PostData:dic FinishBlock:^(id  _Nonnull data) {
        [SVProgressHUD dismiss];
        if ([data isKindOfClass:[NSDictionary class]]) {
            //请求成功
            NSInteger code = [[data valueForKey:@"code"] integerValue];
            if (code == 10000) {
                NSDictionary *resultDic = [data valueForKey:@"data"];
                if ([resultDic isKindOfClass:[NSDictionary class]]) {
                    
                    NSInteger type = [[resultDic valueForKey:@"type"] integerValue];
                    NSDictionary *userApplyRecommender = [resultDic valueForKey:@"userApplyRecommender"];
                    AgentReviewModel *model;
                    if ([userApplyRecommender isKindOfClass:[NSDictionary class]]) {
                        model = [AgentReviewModel modelWithDictionary:userApplyRecommender];
                    }
                    model.type = type;
                    comption(YES,model);

                } else {
                    comption(NO,nil);
                }
            }
        }
    } FailedBlock:^(NSError * _Nonnull error) {
        comption(NO,nil);
        [SVProgressHUD dismiss];
    }];
}

@end
